package com.example.hp.yuejian5.model;

import com.example.hp.yuejian5.RetrofitListener.RetrofitListener;
import com.example.hp.yuejian5.bean.ShowBean;
import com.example.hp.yuejian5.service.ShowService;
import com.example.hp.yuejian5.service.Show_DetailService;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import static com.example.hp.yuejian5.other.url.PICTUREURL;

public class Show_DetailModel {
    private Retrofit retrofit;
    private Show_DetailService show_detailService;

    public Show_DetailModel()
    {
        retrofit=new Retrofit.Builder()
                .baseUrl(PICTUREURL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        show_detailService=retrofit.create(Show_DetailService.class);
    }
    public void showDetail(String picture_id,final RetrofitListener listener)
    {
        Call<ShowBean> call=show_detailService.showdetail(picture_id);
        call.enqueue(new Callback<ShowBean>() {
            @Override
            public void onResponse(Call<ShowBean> call, Response<ShowBean> response) {
                listener.onSuccess(response.body(),1);
            }

            @Override
            public void onFailure(Call<ShowBean> call, Throwable t) {
                listener.onFail();
            }
        });
    }
}
